<?php

/*
	info: 首页框架模块
	date: 11-01-15
*/

if (!defined('ADMIN_WEBINROOT'))
{
	header("HTTP/1.0 404 Not Found");
	exit();
}

$webglobal['file_index'] = array();
$webglobal['adminremurl'] = FALSE;

//框架右边-系统状态
if ($webglobal['mode']=='indexmain')
{
	global_ClearCookie('adminlasturl');
	$webserver['serverip'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '';
	$webserver['serverinfo'] = PHP_OS.' / PHP v'.PHP_VERSION;
	$webserver['serverinfo'] .= @ini_get('safe_mode') ? ' Safe Mode' : '';
	$webserver['dbversion'] = $db->Result($db->Query("SELECT VERSION()"), 0);
	$webserver['fileupload'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'NO';
	$webserver['dbsize'] = 0;
	$query = $db->Query("SHOW TABLE STATUS LIKE '{$webconfig['dbpre']}%'", 'SILENT');
	while ($temptable = $db->FetchArray($query))
	{
		$webserver['dbsize'] += $temptable['Data_length'] + $temptable['Index_length'];
	}
	unset($temptable);
	$webserver['dbsize'] = global_FileSize($webserver['dbsize']);
}

//框架顶部
elseif ($webglobal['mode']=='indexhead')
{
	
}

//框架左边
elseif ($webglobal['mode']=='indexleft') {
	//get all purview
	$webglobal['file_index']['indexMenuData'] = array();
	$tempMenuData = array();
	$tempPurviewArray = explode(',', $user['adminpurview']);

	$query = $db->query("SELECT * FROM {$webconfig['dbpre']}purview ORDER BY upid ASC, `order` DESC, id");
	while ($tempData = $db->FetchArray($query)) {
		if ($tempData['upid'] == 0) {
			$tempMenuData[$tempData['id']] = array(
				'name' => $tempData['name'],
				'modeshow' => array()
			);
		} else {
			if (isset($tempMenuData[$tempData['upid']]) && ($user['issystem'] || global_CheckHaveVar($user['adminpurview'], $tempData['id'])) && $tempData['order'] >= 0) {
				$tempData['url'] = 'mode='.$tempData['mode'];
				$tempData['url'] .= $tempData['linkmore'] ? '&'.$tempData['linkmore'] : '';
				$tempMenuData[$tempData['upid']]['modeshow'][$tempData['id']] = $tempData;
				//$webglobal['file_index']['indexMenuData'][$tempData['upid']]['modeshow'][$tempData['id']] = $tempData;
			}
		}
	}

	$webglobal['file_index']['indexMenuData'] = array_filter($tempMenuData, 'filterEmpty');
}

//框架
elseif ($webglobal['mode']=='index')
{
	$webglobal['file_index']['varindexmain'] = ADMIN_WEBURLPATH.'/index.php?mode=indexmain';
	if (isset($webcookie['adminlasturl']) && !empty($webcookie['adminlasturl']))
	{
		$webglobal['file_index']['varindexmain'] = $webcookie['adminlasturl'];
	}
}

function filterEmpty($menu) {
	return $menu['modeshow'];
}

template_Display('indexshow', 1);

?>